local extension = Package:new("yj2011")
extension.extensionName = "yj"

Fk:loadTranslationTable{
  ["yj2011"] = "将一",
}

local jueqing = fk.CreateTriggerSkill{
    name = "jueqing",
    anim_type = "offensive",
    frequency = Skill.Compulsory,
    events = {fk.DamageCaused},
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(self.name) and data.from == player
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local num = data.damag
      data.damage = 0
      room:loseHp(data.to, num, self.name)
    end,
}

local shangshi = fk.CreateTriggerSkill{
    name = "shangshi",
    anim_type = "defensive",
    events = {fk.AfterCardsMove, fk.HpChanged},
    can_trigger = function(self, event, target, player, data)
      local cards = player:getCardIds(Player.Hand)
    
      if(target) then 
        if target == player and player:hasSkill(self.name) and #cards < (player.maxHp - player.hp) then
          self.cost_data = #cards
          return true
        end
      else
        if player:hasSkill(self.name) and #cards < (player.maxHp - player.hp) then
          self.cost_data = #cards
          return true
        end
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local num = self.cost_data
      local cardNum = math.min(((player.maxHp - player.hp) - num), (player.maxHp - num))

      room:drawCards(player, cardNum, self.name)
    end,
}

local zhangchunhua = General:new(extension, "zhangchunhua", "wei", 3 ,3 ,General.Female)
zhangchunhua:addSkill(jueqing)
zhangchunhua:addSkill(shangshi)

Fk:loadTranslationTable{
  ["zhangchunhua"] = "张春华",
  ["jueqing"] = "绝情",
  [":jueqing"] = "锁定技，你即将造成的伤害视为失去体力。",
  ["shangshi"] = "伤势",
  [":shangshi"] = "当你的手牌数小于X时，你可以将手牌摸至X张（X为你已损失的体力值）。",
}

return extension;